﻿namespace IQIGame.Onigao.GamePlay
{
    public static class APIAttributeUIUtils
    {
        public const float FACTOR = 0.01f;

        static public string GetStrAttributeValue(int showType, int attrValue)
        {
            return showType switch
            {
                1 => GetStrAttributeValueRate(attrValue),
                _ => GetStrAttributeValueNum(attrValue),
            };
        }

        static private string GetStrAttributeValueRate(int attrValue)
        {
            float rate = FACTOR * attrValue;
            int rateInt = (int)rate;
            if (rateInt == rate)
            {
                return rateInt + "%";
            }
            return rate.ToString("0.00") + "%";
        }

        static private string GetStrAttributeValueNum(int attrValue)
        {
            return APIUIConst.GetNumStr(attrValue);
        }
    }
}
